package com.dfec.water.dao;

import com.dfec.framework.mybatis.core.mapper.BaseMapperX;
import com.dfec.framework.mybatis.core.page.PageParam;
import com.dfec.framework.mybatis.core.page.PageUtils;
import com.dfec.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dfec.water.entity.YdbDeviceTypeDictEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

/**
 * 设备类别维护Dao接口
 *
 * @author df
 * @date Thu Feb 06 11:10:12 CST 2025
 */
@Mapper
public interface YdbDeviceTypeDictDao extends BaseMapperX<YdbDeviceTypeDictEntity> {

    /**
     * description:分页查询
     *
     * @param pageParam 分页参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    default PageUtils selectPage(PageParam<YdbDeviceTypeDictEntity> pageParam) {
        YdbDeviceTypeDictEntity entity = pageParam.getEntity() == null ? new YdbDeviceTypeDictEntity() :pageParam.getEntity();
        return this.selectPage(pageParam, dealParams(entity));
    }


    /**
     * 不带分页查询
     * @param ydbDeviceTypeDictEntity
     * @return
     */
    default  List<YdbDeviceTypeDictEntity> selectAll(YdbDeviceTypeDictEntity ydbDeviceTypeDictEntity){
        return this.selectList(dealParams(ydbDeviceTypeDictEntity));
    }

    /**
     * description:查询条件拼接
     *
     * @param entity 参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    public default LambdaQueryWrapperX<YdbDeviceTypeDictEntity> dealParams(YdbDeviceTypeDictEntity entity){
        return new LambdaQueryWrapperX<YdbDeviceTypeDictEntity>()
                .eqIfPresent(YdbDeviceTypeDictEntity::getPid, entity.getPid())
                .likeIfPresent(YdbDeviceTypeDictEntity::getName, entity.getName())
                .eqIfPresent(YdbDeviceTypeDictEntity::getCode, entity.getCode())
                .eqIfPresent(YdbDeviceTypeDictEntity::getLogo, entity.getLogo())
                ;
    }



}
